<?php
//Stored Procedure eklenebilir.
class DBClass{

	//Ayarlar dosyasına aktarılacak
	var $dbuser = "root";
	var $dbpassword = "";
	var $dbname = "infophp";
	var $dbhost = "192.168.1.55:3306";

	function __construct($dbuser='', $dbpassword='', $dbname='', $dbhost='localhost'){
		//		$this->dbuser = $dbuser;
	}
	function  Query($query){
		$returnVal = '';
		$connect = 	mysql_connect($this->dbhost,$this->dbuser,$this->dbpassword);
		if (!$connect) {
			die('Could not connect: ' . mysql_error());
		}
		$db_selected = mysql_select_db($this->dbname, $connect);
		if (!$db_selected) {
			die ('Can\'t use db : ' . mysql_error());
		}
		$query = trim($query);
		$result = mysql_query($query);

		if ( preg_match("/^(insert|INSERT|delete|DELETE|update|UPDATE|replace|REPLACE)\s+/i",$query)){
			//insert,delete,update
		}else{
			//select
			$dt = array();
			$i=0;
			while($row = mysql_fetch_array($result))
			{
					$dt[$i] = $row;
				$i++;
			}
			mysql_free_result($result);
			$returnVal = $dt;
		}
		mysql_close($connect);
		return $returnVal;
	}
}
?>